package com.hsnn.medstgmini.complain.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

import com.hsnn.medstgmini.base.dict.dao.impl.BaseHibernateDAO;
import com.hsnn.medstgmini.complain.dao.SysComplainProdDao;

/**
 * @category 申投诉企业产品 DAO接口实现类
 * @author 韩守松
 * @date 2015年9月11日
 */
@Repository
public class SysComplainProdDaoImpl extends BaseHibernateDAO implements
		SysComplainProdDao {
	/**
	 * @category 根据申投诉id 获取申投诉企业产品列表
	 * @author 韩守松
	 * @date 2015年9月11日
	 * @param @param complainId
	 * @param @return
	 */
	@SuppressWarnings("rawtypes")
	public List getSysComplainProdById(String complainId) {
		StringBuffer hql = new StringBuffer();
		hql.append(" select ");
		hql.append(" scd.sys_complain_drug sysComplainDrug, ");
		hql.append(" scd.complain_id complainId, ");
		hql.append(" scd.prod_id prodId, ");
		hql.append(" b.qualityspec_name drugName  ");
		hql.append(" from sys_complain_prod scd ");
		hql.append(" join std_proddruginfo sd on  scd.prod_id = sd.prod_id  ");
		hql.append(" left JOIN std_drugqualityspec b ON sd.qualityspec_id = b.qualityspec_id ");
		hql.append(" where scd.complain_id = :complainId ");
		Query query = getSession().createSQLQuery(hql.toString());
		query.setString("complainId", complainId);
		query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
		List list = query.list();
		return list.size()>0?list:null;
	}
}
